-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
types: remove void
from Maybe<T>
and update SuiteSelectors
#1074
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
bc33c20
to
41154ac
Compare
41154ac
to
e2d417c
Compare
e2d417c
to
b44b1cb
Compare
Hey, @vonagam, I think I missed this diff. Sorry. Thank you for making this PR Here's the issue I was trying to resolve using Basically, TS treats undefined and void differently in function returns. Didn't dig into it, but removing void from An alternative would be to add |
Also, I am not fully sure what would cause the issue you're seeing. Can you put a repro on codesandbox and I'll try to look at it? Wondering if it is a pnpm thing, vest thing, or something completely different. Tried a quick repro on CodeSandbox and I didn't experiecne it, so interesting to see why it is behaving like that. |
About repo: I have not used codesandbox much but this is part of an example that produces the error: export class Wrapper {
//...
getError() { // <- mentioned error will be there
return this.suiteResult.getError();
}
} Need to have About no return: No return functions can be assigned to type of functions with undefined return without a problem - playground. But void functions (so typed as void) cannot be assigned to anything besides void functions - playground. So what you shown can be made work without an error but something prevents it. Edit: Intersting, |
b44b1cb
to
8e1cac5
Compare
Annoying, so in microsoft/TypeScript#36288 ts got ability to accept As for now, removed modification to |
For record, seems like |
0cc21fa
to
ca735df
Compare
8e1cac5
to
ce83094
Compare
Ok, two things. First, published my integration of vest for svelte. So now it should be possible to see the errors I am talking about. Let's take this code: getError(): Suite.Failure<V, A> | undefined {
return this.summaryStore.value.getError() as any;
} Ideally I would want not to specify types and let everything be inferred: getError() {
return this.summaryStore.value.getError();
} But if I do that and run
So I am required to specify a type, but if I do it like this: getError(): Suite.Failure<V, A> | undefined {
return this.summaryStore.value.getError();
} Then I get an error that says:
That's the problem I am trying to solve. Second, so I've reverted PR to almost initial state where I removed Thoughts? |
This seems reasonable. I created Maybe as a very simple helper utility type to help me cope with having to type things repeatedly, but OTOH, maybe that's not the best option when exposing a publicly facing API, and the best approach is to be explicit to begin with. Let me just test this locally real quick, and if this works, I'll merge, and release a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, all the tests pass and the build runs correctly too. Merging, and releasing a @next version. Release will finish in 10 minutes approximately
Also, @vonagam, the vest-for-svelte repo looks great! Thank you so much for working on it |
Thanks. Yes, of course, have nothing against the library being listed there. |
OK, @vonagam, I'll add the resource to the website tomorrow, I'm after a very long international flight, so it will take me just a little bit more time. Thank you for all the effort you're putting into Vest! |
Ok, with that version I can remove But seems like I still need to specify return type because Can I add this change? (Checking because you made a release, don't want to mess things up.) |
@vonagam, yes, sure. Go ahead. The release goes through a separate branch, no issues there. |
ce83094
to
feccfd9
Compare
@vonagam - OK, @next now is |
Yep, works without a problem. |
@vonagam, released as [email protected] |
In #1070 I've referenced
Maybe
in exported type. Did not know thatMaybe
is an internal helper type. Because of this I've met errors of such sort:So this PR removes
Maybe
usage fromSuiteSelectors
.But while doing it I've encountered resistance from typescript because
Maybe<T>
is currently defined asT | undefined | void
. I think it is mistake to includevoid
because it is a special thing - something likeunknown
but one that you should not touch at all, only discard. So I've changedMaybe
to simpleT | undefined
.